package com.seventh.parkingrent.common;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 白秋洋
 * @Date: 2021/08/25/11:51
 * @Description:
 */
public class Encrypt {
    public static String md5(String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchAlgorithmException {

        MessageDigest md5 = MessageDigest.getInstance("MD5");

        Base64.Encoder encoder = Base64.getEncoder();

        String md5Str = encoder.encodeToString(md5.digest(password.getBytes("utf-8")));

        return md5Str;
    }
}
